CREATE TABLE [dbo].[Student]
(
[nCode] [numeric] (18, 0) NOT NULL,
[Nn_abit] [numeric] (18, 0) NULL,
[ik_medal] [int] NOT NULL,
[Ik_vid_pens] [int] NULL CONSTRAINT [DF_Stud_Ik_vid_pens] DEFAULT ((1)),
[Ik_podg] [int] NULL,
[Ik_ob_rab] [int] NULL,
[Ik_special_uchet] [int] NULL,
[Ik_zaved] [int] NULL CONSTRAINT [DF_Stud_Ik_zaved] DEFAULT ((1)),
[Ngodokon] [numeric] (18, 0) NULL,
[Cdopsved] [varchar] (2000) COLLATE Cyrillic_General_CI_AS NULL,
[ik_pred] [int] NULL,
[cDolgnost] [varchar] (50) COLLATE Cyrillic_General_CI_AS NULL,
[StazYear] [int] NULL,
[StazMonth] [int] NULL,
[cLgot] [varchar] (500) COLLATE Cyrillic_General_CI_AS NULL,
[cOsnovan] [varchar] (50) COLLATE Cyrillic_General_CI_AS NULL,
[Login] [varchar] (6) COLLATE Cyrillic_General_CI_AS NOT NULL,
[Password] [varchar] (15) COLLATE Cyrillic_General_CI_AS NOT NULL,
[Email] [varchar] (30) COLLATE Cyrillic_General_CI_AS NOT NULL
)
GO
ALTER TABLE [dbo].[Student] ADD CONSTRAINT [StudentLoginUnique] UNIQUE NONCLUSTERED  ([Login])

GO
ALTER TABLE [dbo].[Student] ADD CONSTRAINT [StudentEmailUnique] UNIQUE NONCLUSTERED  ([Email])

GO
ALTER TABLE [dbo].[Student] WITH NOCHECK ADD CONSTRAINT [CheckStudentNgodokon] CHECK (([Ngodokon]<=datepart(year,getdate()) AND [Ngodokon]>(1950)))
GO
ALTER TABLE [dbo].[Student] ADD CONSTRAINT [PK_Stud] PRIMARY KEY CLUSTERED  ([nCode]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[Student] ADD CONSTRAINT [FK_Student_Person] FOREIGN KEY ([nCode]) REFERENCES [dbo].[Person] ([nCode])
GO
